package com.team12.hotel404.controller.common;

import com.team12.hotel404.domain.Hotel;
import com.team12.hotel404.domain.Room;
import com.team12.hotel404.service.HotelService;
import com.team12.hotel404.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 页面跳转控制
 */
@Controller
@RequestMapping(value = "/pages")
public class toPages {

    @Autowired
    private HotelService hotelService;

    @Autowired
    private RoomService roomService;

    @RequestMapping(value = "/admin-index")
    public String to_admin_index(){
        return "admin/admin-index";
    }

    /**
     * @author：王畅
     * @return  登陆注册界面
     */

    @RequestMapping(value = "/toHotel")
    public String to_userLogin(Model model){
        List<Hotel> hotel= hotelService.listHotelBySales();
        model.addAttribute("hotels",hotel);
        return "/user/hotelIndex";
    }

    @GetMapping(value = "hotelShow")
    public String roomPage(Model model,Integer id){
        Hotel hotel = hotelService.findById(id);
        model.addAttribute("hotel",hotel);

        List<Room> room = roomService.findRoomByHotelId(id);
        model.addAttribute("rooms",room);

        return "Page/1hotel1";

    }


    @RequestMapping(value = "/toRegist")
    public String to_userRegist(){return "/user/newRegist";}



}
